<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no"/>
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <meta name="renderer" content="webkit">
    <meta name="format-detection" content="telephone=no">
    <meta name="csrf-param" content="_homeCSRF">
    <meta name="csrf-token" content="NzBwRHI2NEYGHUgQLW5BMgJeMQ5GW1YMUFtGJQEBcDVzAiMOS39cdg==">
    <title>企业内刊</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link href="../src/img/favicon.ico" rel="shortcut icon">
    <link href="/images/favicon.ico" rel="bookmark">
    <link href="../src/css/jquery.bxslider.css" rel="stylesheet">
    <link href="../src/iconfonts/iconfont.css" rel="stylesheet">
    <link href="../src/css/bootstrap.css" rel="stylesheet">
    <link href="../src/css/dookayui.css" rel="stylesheet">
    <link href="../src/css/dx.css" rel="stylesheet">
    <link href="../src/css/dy.css" rel="stylesheet">
    <!--[if lte IE9]>
    <script src="../src/js/html5shiv.js"></script>
    <![endif]-->
    <!--[if lte IE9]>
    <script src="../src/js/respond.min.js"></script>
    <![endif]-->
</head>
<body>

<div class="header"></div>
<div id="pbody" class="dx-content">
    <div class="dy-list-show">
        <div class="container">
            <div class="title mb-5 pengxin-news-title">
                <p class="font-20 article-title"></p>
            </div>
            <div class="dx-magazine-content">
                <!--<a target="_blank" href="../src/img/1507541846325449.pdf" class="dx-magazine">
                    <img src="../src/img/1507541874330268_231x292x80.png" alt="1507541853(1).png">
                    <p>2017年9月总第42期</p>
                </a>-->
            </div>

        </div>
    </div>
</div>
<nav class="text-center" style="margin: 5% 0;">
</nav>
<footer class="footer"></footer>


<script src="../src/js/dookayui.min.js"></script>
<script src="../src/js/common.js"></script>
<script>
    $(function () {
        commonApp.init();
    })
    $(document).ready(function () {

        $(".header").load("http://192.168.100.181:8080/huoge-edu/public-file/secondMenu-header.html", function () {
            $(".px-mobile .dy-nav .bread").on("click", function () {
                $(".px-mobile .main-nav").slideToggle("slow");
            });
        });
        $(".footer").load("http://192.168.100.181:8080/huoge-edu/public-file/footer.html");
    });


    //动态获取PDF
    function serilizeURL(url) {
        var rs = url.split("?")[1];
        var arr = rs.split("&");
        var json = {};
        for (var i = 0; i < arr.length; i++) {
            if (arr[i].indexOf("=") != -1) {
                json[arr[i].split("=")[0]] = arr[i].split("=")[1];
            }
            else {
                json[arr[i]] = "undefined";
            }
        }
        return json;
    }

    window.current_url = location.href;
    var aidSid = serilizeURL(current_url);


    //获取所有PDF
    function getAllVideos(a, b) {

        var PDFLists;
        var PDFListsLength;

        $.ajax({
            url: "http://192.168.100.181:8080/api/pdf/getPdfUrl/",
            success: function (data) {

                PDFLists = data.data;
                PDFListsLength = PDFLists.length;

                $('.dx-magazine-content').empty();
                $('.text-center').empty();
                $('.text-center').append(`
                    <ul class="pagination" style="margin-top: 10px;">
                        <a class="add-a-style prev" href="javascript:void(0)" selectPage="0">上一页</a>
                        <span></span>
                        <a class="add-a-style next" href="javascript:void(0)" selectPage="0">下一页</a>
                    </ul>`)

                function pagingContent(i) {
                    $('.dx-magazine-content').append(`
                            <a target="_blank" href=${PDFLists[i].url} class="dx-magazine">
                                <img src=${PDFLists[i].coverImgUrl} alt="">
                                <p>${PDFLists[i].title}</p>
                            </a>
                          `);
                }

                //分页
                var Count = PDFListsLength;//记录条数
                var PageSize = 12;//设置每页示数目
                var PageCount = Math.ceil(Count / PageSize);//计算总页数
                var currentPage = 1;//当前页，默认为1
                var selectPage = '';//当前在哪一页

                //分页按钮
                for (var i = 1; i <= PageCount; i++) {
                    var pageN = '<a class="add-a-style" href="javascript:void(0)" selectPage="' + i + '">' + i + '</a>';
                    $('.text-center .pagination span').append(pageN);
                }
                //显示默认页（第一页）
                for (i = (currentPage - 1) * PageSize; i < PageSize * currentPage; i++) {
                    selectPage = i;
                    pagingContent(selectPage);
                    $('.text-center span a:nth-child(1)').addClass('on');

                }
                //显示选择页的内容
                $('.text-center span a').click(function () {
                    selectPage = $(this).attr('selectPage');
                    $(this).addClass('on').siblings().removeClass('on');
                    $('.dx-magazine-content').html('');
                    for (i = (selectPage - 1) * PageSize; i < PageSize * selectPage; i++) {
                        pagingContent(i);
                    }
                });
                $(".next").click(function () {

                    currentPage= $($('.on')[0]).attr('selectPage');
                    currentPage=parseInt(currentPage)+1; //当前页数
                    $('.text-center span a').eq(currentPage-1).addClass('on').siblings().removeClass('on');

                    if (currentPage <= PageCount) {
                        $('.dx-magazine-content').html('');
                        for (i = (currentPage - 1) * PageSize; i < PageSize * currentPage; i++) {
                            pagingContent(i);
                        }
                    } else {
                        return;
                    }
                });
                $(".prev").click(function () {

                    currentPage= $($('.on')[0]).attr('selectPage');
                    currentPage=parseInt(currentPage)-1; //当前页数
                    $('.text-center span a').eq(currentPage - 1).addClass('on').siblings().removeClass('on');

                    if (currentPage > 0) {
                        $('.dx-magazine-content').html('');
                        for (i = (currentPage - 1) * PageSize; i < PageSize * currentPage; i++) {
                            pagingContent(i);
                        }
                    } else {
                        return;
                    }
                });

            }
        });

    }

    getAllVideos(aidSid.pid, aidSid.secondMenuId);

</script>
</body>
</html>
